import javax.swing.*; 
import javax.swing.event.*; 
import javax.swing.table.*; 
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.util.*;

public class NutritionFrame extends JPanel {

	/**
	 * 
	 */
	private static final long serialVersionUID = 5430836653494395465L;
	JTabbedPane tab;
	java.util.List<NutritionTableView> tables;
	
	public NutritionFrame(){
		super(new BorderLayout());
		tables=new ArrayList<NutritionTableView>();
	}
	
	public void config(){
		tab=new JTabbedPane();
//		NutritionTableView table=new NutritionTableView("new group",4,"",false);
//		table.config();
//		tables.add(table);
//		tab.add("new group",table.panel);
		add(tab,"Center");
	}
	
	public void addGroup(String name, int retention,String description, boolean identifiable){
		NutritionTableView table=new NutritionTableView(name,retention,description,identifiable);
		table.config();
		tables.add(table);
		tab.add(name,table);
		tab.setSelectedComponent(table);
	}
	
	public void setGroupInfo(int i,String name, int retention,String description,boolean identifiable){
		tables.get(i).setName(name);
		tables.get(i).setRetention(retention);
		tables.get(i).setDescription(description);
		tables.get(i).setIdentifiable(identifiable);
		tab.setTitleAt(i, name);
		tab.setSelectedIndex(i);
	}
	
	public void delGroup(int i){
		if(i<tables.size()){
			tables.remove(i);
			tab.remove(i);
		}
	}
	
 }
